package com.batchbrake.queue;

import javax.swing.ImageIcon;
import javax.swing.table.DefaultTableModel;

public class SubtitlesTableModel extends DefaultTableModel  {
	public static ImageIcon icnSubtitle = new ImageIcon("images/SUB.png");
	public static final int COL_SUBTITLE = 0;
	public static final int COL_ENCODING = 1;
	public static final int COL_LANG = 2;
	
	private QueueEntity entity = null;

	public void setEntity(QueueEntity entity) {
		this.entity = entity;
	}
	
	public QueueEntity getEntity() {
		return this.entity;
	}
	
	@Override
	public Class<?> getColumnClass(int col) {
		switch( col ) {
		case COL_SUBTITLE:
		case COL_ENCODING:
		case COL_LANG:
			return String.class;
		}
		return null;
	}

	@Override
	public int getColumnCount() {
		return 3;
	}

	@Override
	public String getColumnName(int col) {
		return null;
	}

	@Override
	public int getRowCount() {
		if( entity != null ) {
			return entity.getSubtitles().size();
		} else {
			return 0;
		}
	}

	@Override
	public Object getValueAt(int row, int col) {
		switch( col ) {
		case COL_SUBTITLE:
			return entity.getSubtitles().get(row).getName();
		case COL_ENCODING:
			return entity.getEncodings().get(row);
		case COL_LANG:
			return entity.getLangs().get(row);
		}
		return null;
	}

	@Override
	public boolean isCellEditable(int row, int col) {
		return false;
	}

}
